package cn.ad.server.web.exception;

import cn.ad.server.domain.enumration.ReturnCode;

import java.text.MessageFormat;

/**
 * @author dongbin.yu
 * @from 2016-05-25
 * @since V1.0
 */
public class AdServerMessageException extends RuntimeException {

    private ReturnCode returnCode;

    public AdServerMessageException(String message) {
        super(message);
    }

    public AdServerMessageException(ReturnCode returnCode, String... args) {

        super(MessageFormat.format(returnCode.getDescription(), args));
        this.returnCode = returnCode;
    }

    public AdServerMessageException(Throwable cause, ReturnCode returnCode, String... args) {

        super(MessageFormat.format(returnCode.getMessage(), args), cause);
        this.returnCode = returnCode;
    }

    public ReturnCode getReturnCode() {
        return returnCode;
    }
}
